<html>
<head>
  <script src="sorttable.js"></script>
  <script src="sourceview.js"></script>
  <link rel="stylesheet" type="text/css" href="style.css">
  <title>zcov: /home/vagrant/workspace/proj_libjpeg/cov/rdtarga.c</title>
</head>
<body>
<center><h1> zcov: <a href="index.html">/home/vagrant/workspace/proj_libjpeg/cov</a>/<a href="rdtarga.c.html">rdtarga.c</a> </h1></center>
<hr>


<center>
<table id="headertable" cellpadding=2>
  <tr>
    <td bgcolor=#ACACFF> <b>Files:</b> </td>
    <td bgcolor=#F0F0FF> 1 </td>
    <td width="30"></td>
    <td bgcolor=#ACACFF> <b>Branches&nbsp;Taken:</b> </td>
    <td bgcolor=#F0F0FF align=right> <b>90.5%<b> </td>
    <td bgcolor=#F0F0FF align=right> 67&nbsp;/&nbsp;74 </td>
  </tr>
  <tr>
    <td bgcolor=#ACACFF> <b>Generated:</b> </td>
    <td bgcolor=#F0F0FF> 2016-04-07&nbsp;18:20 </td>
    <td width="30"></td>
    <td bgcolor=#ACACFF> <b>Branches&nbsp;Executed:</b> </td>
    <td bgcolor=#F0F0FF align=right> <b>97.3%<b> </td>
    <td bgcolor=#F0F0FF align=right> 72&nbsp;/&nbsp;74 </td>
  </tr>
  <tr>
    <td colspan=2> </td>
    <td width="30"></td>
    <td bgcolor=#ACACFF> <b>Line&nbsp;Coverage:</b> </td>
    <td bgcolor=#F0F0FF align=right> <b>88.2%</b> </td>
    <td bgcolor=#F0F0FF align=right> 164&nbsp;/&nbsp;186 </td>
  </tr>
</table>
</center>
<p>
<hr>

<center>
<table id="fileheadertable" cellpadding=2>
  <tr>
    <td bgcolor=#ACACFF> <b>Programs:</b> </td>
    <td bgcolor=#F0F0FF> 1 </td>
    <td width="30"></td>
    <td bgcolor=#ACACFF> <b>Runs</b> </td>
    <td bgcolor=#F0F0FF align=right> 6326 </td>
  </tr>
</table>
</center>
<p>
<hr>

<pre>
<span class="lineNum">       1 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">       2 </span>                :  * rdtarga.c
<span class="lineNum">       3 </span>                :  *
<span class="lineNum">       4 </span>                :  * Copyright (C) 1991-1996, Thomas G. Lane.
<span class="lineNum">       5 </span>                :  * This file is part of the Independent JPEG Group's software.
<span class="lineNum">       6 </span>                :  * For conditions of distribution and use, see the accompanying README file.
<span class="lineNum">       7 </span>                :  *
<span class="lineNum">       8 </span>                :  * This file contains routines to read input images in Targa format.
<span class="lineNum">       9 </span>                :  *
<span class="lineNum">      10 </span>                :  * These routines may need modification for non-Unix environments or
<span class="lineNum">      11 </span>                :  * specialized applications.  As they stand, they assume input from
<span class="lineNum">      12 </span>                :  * an ordinary stdio stream.  They further assume that reading begins
<span class="lineNum">      13 </span>                :  * at the start of the file; start_input may need work if the
<span class="lineNum">      14 </span>                :  * user interface has already read some data (e.g., to determine that
<span class="lineNum">      15 </span>                :  * the file is indeed Targa format).
<span class="lineNum">      16 </span>                :  *
<span class="lineNum">      17 </span>                :  * Based on code contributed by Lee Daniel Crocker.
<span class="lineNum">      18 </span>                :  */</FONT></I>
<span class="lineNum">      19 </span>                : 
<span class="lineNum">      20 </span>                : #<B><FONT COLOR="#5F9EA0">include</FONT></B> <B><FONT COLOR="#BC8F8F">&quot;cdjpeg.h&quot;</FONT></B>		<I><FONT COLOR="#B22222">/* Common decls for cjpeg/djpeg applications */</FONT></I>
<span class="lineNum">      21 </span>                : 
<span class="lineNum">      22 </span>                : #<B><FONT COLOR="#5F9EA0">ifdef</FONT></B> <FONT COLOR="#B8860B">TARGA_SUPPORTED</FONT>
<span class="lineNum">      23 </span>                : 
<span class="lineNum">      24 </span>                : 
<span class="lineNum">      25 </span>                : <I><FONT COLOR="#B22222">/* Macros to deal with unsigned chars as efficiently as compiler allows */</FONT></I>
<span class="lineNum">      26 </span>                : 
<span class="lineNum">      27 </span>                : #<B><FONT COLOR="#5F9EA0">ifdef</FONT></B> <FONT COLOR="#B8860B">HAVE_UNSIGNED_CHAR</FONT>
<span class="lineNum">      28 </span>                : <B><FONT COLOR="#228B22">typedef</FONT></B> <B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B> U_CHAR;
<span class="lineNum">      29 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <B><FONT COLOR="#0000FF">UCH</FONT></B>(x)	((int) (x))
<span class="lineNum">      30 </span>                : #<B><FONT COLOR="#5F9EA0">else</FONT></B> <I><FONT COLOR="#B22222">/* !HAVE_UNSIGNED_CHAR */</FONT></I>
<span class="lineNum">      31 </span>                : #<B><FONT COLOR="#5F9EA0">ifdef</FONT></B> <FONT COLOR="#B8860B">CHAR_IS_UNSIGNED</FONT>
<span class="lineNum">      32 </span>                : <B><FONT COLOR="#228B22">typedef</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B> U_CHAR;
<span class="lineNum">      33 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <B><FONT COLOR="#0000FF">UCH</FONT></B>(x)	((int) (x))
<span class="lineNum">      34 </span>                : #<B><FONT COLOR="#5F9EA0">else</FONT></B>
<span class="lineNum">      35 </span>                : <B><FONT COLOR="#228B22">typedef</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B> U_CHAR;
<span class="lineNum">      36 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <B><FONT COLOR="#0000FF">UCH</FONT></B>(x)	((int) (x) &amp; 0xFF)
<span class="lineNum">      37 </span>                : #<B><FONT COLOR="#5F9EA0">endif</FONT></B>
<span class="lineNum">      38 </span>                : #<B><FONT COLOR="#5F9EA0">endif</FONT></B> <I><FONT COLOR="#B22222">/* HAVE_UNSIGNED_CHAR */</FONT></I>
<span class="lineNum">      39 </span>                : 
<span class="lineNum">      40 </span>                : 
<span class="lineNum">      41 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B>	<B><FONT COLOR="#0000FF">ReadOK</FONT></B>(file,buffer,len)	(JFREAD(file,buffer,len) == ((size_t) (len)))
<span class="lineNum">      42 </span>                : 
<span class="lineNum">      43 </span>                : 
<span class="lineNum">      44 </span>                : <I><FONT COLOR="#B22222">/* Private version of data source object */</FONT></I>
<span class="lineNum">      45 </span>                : 
<span class="lineNum">      46 </span>                : <B><FONT COLOR="#228B22">typedef</FONT></B> <B><FONT COLOR="#228B22">struct</FONT></B> _tga_source_struct * tga_source_ptr;
<span class="lineNum">      47 </span>                : 
<span class="lineNum">      48 </span>                : <B><FONT COLOR="#228B22">typedef</FONT></B> <B><FONT COLOR="#228B22">struct</FONT></B> _tga_source_struct {
<span class="lineNum">      49 </span>                :   <B><FONT COLOR="#228B22">struct</FONT></B> cjpeg_source_struct pub; <I><FONT COLOR="#B22222">/* public fields */</FONT></I>
<span class="lineNum">      50 </span>                : 
<span class="lineNum">      51 </span>                :   j_compress_ptr cinfo;		<I><FONT COLOR="#B22222">/* back link saves passing separate parm */</FONT></I>
<span class="lineNum">      52 </span>                : 
<span class="lineNum">      53 </span>                :   JSAMPARRAY colormap;		<I><FONT COLOR="#B22222">/* Targa colormap (converted to my format) */</FONT></I>
<span class="lineNum">      54 </span>                : 
<span class="lineNum">      55 </span>                :   jvirt_sarray_ptr whole_image;	<I><FONT COLOR="#B22222">/* Needed if funny input row order */</FONT></I>
<span class="lineNum">      56 </span>                :   JDIMENSION current_row;	<I><FONT COLOR="#B22222">/* Current logical row number to read */</FONT></I>
<span class="lineNum">      57 </span>                : 
<span class="lineNum">      58 </span>                :   <I><FONT COLOR="#B22222">/* Pointer to routine to extract next Targa pixel from input file */</FONT></I>
<span class="lineNum">      59 </span>                :   JMETHOD(<B><FONT COLOR="#228B22">void</FONT></B>, read_pixel, (tga_source_ptr sinfo));
<span class="lineNum">      60 </span>                : 
<span class="lineNum">      61 </span>                :   <I><FONT COLOR="#B22222">/* Result of read_pixel is delivered here: */</FONT></I>
<span class="lineNum">      62 </span>                :   U_CHAR tga_pixel[4];
<span class="lineNum">      63 </span>                : 
<span class="lineNum">      64 </span>                :   <B><FONT COLOR="#228B22">int</FONT></B> pixel_size;		<I><FONT COLOR="#B22222">/* Bytes per Targa pixel (1 to 4) */</FONT></I>
<span class="lineNum">      65 </span>                : 
<span class="lineNum">      66 </span>                :   <I><FONT COLOR="#B22222">/* State info for reading RLE-coded pixels; both counts must be init to 0 */</FONT></I>
<span class="lineNum">      67 </span>                :   <B><FONT COLOR="#228B22">int</FONT></B> block_count;		<I><FONT COLOR="#B22222">/* # of pixels remaining in RLE block */</FONT></I>
<span class="lineNum">      68 </span>                :   <B><FONT COLOR="#228B22">int</FONT></B> dup_pixel_count;		<I><FONT COLOR="#B22222">/* # of times to duplicate previous pixel */</FONT></I>
<span class="lineNum">      69 </span>                : 
<span class="lineNum">      70 </span>                :   <I><FONT COLOR="#B22222">/* This saves the correct pixel-row-expansion method for preload_image */</FONT></I>
<span class="lineNum">      71 </span>                :   JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo,
<span class="lineNum">      72 </span>                : 				       cjpeg_source_ptr sinfo));
<span class="lineNum">      73 </span>                : } tga_source_struct;
<span class="lineNum">      74 </span>                : 
<span class="lineNum">      75 </span>                : 
<span class="lineNum">      76 </span>                : <I><FONT COLOR="#B22222">/* For expanding 5-bit pixel values to 8-bit with best rounding */</FONT></I>
<span class="lineNum">      77 </span>                : 
<span class="lineNum">      78 </span>                : <B><FONT COLOR="#228B22">static</FONT></B> <B><FONT COLOR="#228B22">const</FONT></B> UINT8 c5to8bits[32] = {
<span class="lineNum">      79 </span>                :     0,   8,  16,  25,  33,  41,  49,  58,
<span class="lineNum">      80 </span>                :    66,  74,  82,  90,  99, 107, 115, 123,
<span class="lineNum">      81 </span>                :   132, 140, 148, 156, 165, 173, 181, 189,
<span class="lineNum">      82 </span>                :   197, 206, 214, 222, 230, 239, 247, 255
<span class="lineNum">      83 </span>                : };
<span class="lineNum">      84 </span>                : 
<span class="lineNum">      85 </span>                : 
<span class="lineNum">      86 </span>                : 
<span class="lineNum">      87 </span>                : <B><FONT COLOR="#0000FF">LOCAL</FONT></B>(<B><FONT COLOR="#228B22">int</FONT></B>)
<span class="lineNum">      88 </span><span class="lineCov">            5258: <B><FONT COLOR="#0000FF">read_byte</FONT></B> (tga_source_ptr sinfo)</span>
<span class="lineNum">      89 </span>                : <I><FONT COLOR="#B22222">/* Read next byte from Targa file */</FONT></I>
<span class="lineNum">      90 </span>                : {
<span class="lineNum">      91 </span><span class="lineCov">            5258:   <B><FONT COLOR="#228B22">register</FONT></B> FILE *infile = sinfo-&gt;pub.input_file;</span>
<span class="lineNum">      92 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> c;
<span class="lineNum">      93 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">            1033: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">            4225: branch 2 taken</span>
</span><span class="lineNum">      94 </span><span class="lineCov">            5258:   <B><FONT COLOR="#A020F0">if</FONT></B> ((c = getc(infile)) == EOF)</span>
<span class="lineNum">      95 </span><span class="lineCov">            1033:     ERREXIT(sinfo-&gt;cinfo, JERR_INPUT_EOF);</span>
<span class="lineNum">      96 </span><span class="lineCov">            4225:   <B><FONT COLOR="#A020F0">return</FONT></B> c;</span>
<span class="lineNum">      97 </span>                : }
<span class="lineNum">      98 </span>                : 
<span class="lineNum">      99 </span>                : 
<span class="lineNum">     100 </span>                : <B><FONT COLOR="#0000FF">LOCAL</FONT></B>(<B><FONT COLOR="#228B22">void</FONT></B>)
<span class="lineNum">     101 </span><span class="lineCov">              57: <B><FONT COLOR="#0000FF">read_colormap</FONT></B> (tga_source_ptr sinfo, <B><FONT COLOR="#228B22">int</FONT></B> cmaplen, <B><FONT COLOR="#228B22">int</FONT></B> mapentrysize)</span>
<span class="lineNum">     102 </span>                : <I><FONT COLOR="#B22222">/* Read the colormap from a Targa file */</FONT></I>
<span class="lineNum">     103 </span>                : {
<span class="lineNum">     104 </span>                :   <B><FONT COLOR="#228B22">int</FONT></B> i;
<span class="lineNum">     105 </span>                : 
<span class="lineNum">     106 </span>                :   <I><FONT COLOR="#B22222">/* Presently only handles 24-bit BGR format */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              40: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              17: branch 1 taken</span>
</span><span class="lineNum">     107 </span><span class="lineCov">              57:   <B><FONT COLOR="#A020F0">if</FONT></B> (mapentrysize != 24)</span>
<span class="lineNum">     108 </span><span class="lineCov">              40:     ERREXIT(sinfo-&gt;cinfo, JERR_TGA_BADCMAP);</span>
<span class="lineNum">     109 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              17: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">     110 </span><span class="lineCov">              17:   <B><FONT COLOR="#A020F0">for</FONT></B> (i = 0; i &lt; cmaplen; i++) {</span>
<span class="lineNum">     111 </span><span class="lineCov">              17:     sinfo-&gt;colormap[2][i] = (JSAMPLE) read_byte(sinfo);</span>
<span class="lineNum">     112 </span><span class="lineCov">              17:     sinfo-&gt;colormap[1][i] = (JSAMPLE) read_byte(sinfo);</span>
<span class="lineNum">     113 </span><span class="lineNoCov">               0:     sinfo-&gt;colormap[0][i] = (JSAMPLE) read_byte(sinfo);</span>
<span class="lineNum">     114 </span>                :   }
<span class="lineNum">     115 </span><span class="lineNoCov">               0: }</span>
<span class="lineNum">     116 </span>                : 
<span class="lineNum">     117 </span>                : 
<span class="lineNum">     118 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">     119 </span>                :  * read_pixel methods: get a single pixel from Targa file into tga_pixel[]
<span class="lineNum">     120 </span>                :  */</FONT></I>
<span class="lineNum">     121 </span>                : 
<span class="lineNum">     122 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(<B><FONT COLOR="#228B22">void</FONT></B>)
<span class="lineNum">     123 </span><span class="lineCov">         5582637: <B><FONT COLOR="#0000FF">read_non_rle_pixel</FONT></B> (tga_source_ptr sinfo)</span>
<span class="lineNum">     124 </span>                : <I><FONT COLOR="#B22222">/* Read one Targa pixel from the input file; no RLE expansion */</FONT></I>
<span class="lineNum">     125 </span>                : {
<span class="lineNum">     126 </span><span class="lineCov">         5582637:   <B><FONT COLOR="#228B22">register</FONT></B> FILE *infile = sinfo-&gt;pub.input_file;</span>
<span class="lineNum">     127 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> i;
<span class="lineNum">     128 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">        11672698: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">         5582637: branch 1 taken</span>
</span><span class="lineNum">     129 </span><span class="lineCov">        17255335:   <B><FONT COLOR="#A020F0">for</FONT></B> (i = 0; i &lt; sinfo-&gt;pixel_size; i++) {</span>
<span class="lineNum">     130 </span><span class="lineCov">        11672698:     sinfo-&gt;tga_pixel[i] = (U_CHAR) getc(infile);</span>
<span class="lineNum">     131 </span>                :   }
<span class="lineNum">     132 </span><span class="lineCov">         5582637: }</span>
<span class="lineNum">     133 </span>                : 
<span class="lineNum">     134 </span>                : 
<span class="lineNum">     135 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(<B><FONT COLOR="#228B22">void</FONT></B>)
<span class="lineNum">     136 </span><span class="lineCov">          149719: <B><FONT COLOR="#0000FF">read_rle_pixel</FONT></B> (tga_source_ptr sinfo)</span>
<span class="lineNum">     137 </span>                : <I><FONT COLOR="#B22222">/* Read one Targa pixel from the input file, expanding RLE data as needed */</FONT></I>
<span class="lineNum">     138 </span>                : {
<span class="lineNum">     139 </span><span class="lineCov">          149719:   <B><FONT COLOR="#228B22">register</FONT></B> FILE *infile = sinfo-&gt;pub.input_file;</span>
<span class="lineNum">     140 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> i;
<span class="lineNum">     141 </span>                : 
<span class="lineNum">     142 </span>                :   <I><FONT COLOR="#B22222">/* Duplicate previously read pixel? */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">          107445: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">           42274: branch 1 taken</span>
</span><span class="lineNum">     143 </span><span class="lineCov">          149719:   <B><FONT COLOR="#A020F0">if</FONT></B> (sinfo-&gt;dup_pixel_count &gt; 0) {</span>
<span class="lineNum">     144 </span><span class="lineCov">          107445:     sinfo-&gt;dup_pixel_count--;</span>
<span class="lineNum">     145 </span><span class="lineCov">          256148:     <B><FONT COLOR="#A020F0">return</FONT></B>;</span>
<span class="lineNum">     146 </span>                :   }
<span class="lineNum">     147 </span>                : 
<span class="lineNum">     148 </span>                :   <I><FONT COLOR="#B22222">/* Time to read RLE block header? */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">            5224: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">           37050: branch 1 taken</span>
</span><span class="lineNum">     149 </span><span class="lineCov">           42274:   <B><FONT COLOR="#A020F0">if</FONT></B> (--sinfo-&gt;block_count &lt; 0) { <I><FONT COLOR="#B22222">/* decrement pixels remaining in block */</FONT></I></span>
<span class="lineNum">     150 </span><span class="lineCov">            5224:     i = read_byte(sinfo);</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">            1518: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">            2690: branch 1 taken</span>
</span><span class="lineNum">     151 </span><span class="lineCov">            4208:     <B><FONT COLOR="#A020F0">if</FONT></B> (i &amp; 0x80) {		<I><FONT COLOR="#B22222">/* Start of duplicate-pixel block? */</FONT></I></span>
<span class="lineNum">     152 </span><span class="lineCov">            1518:       sinfo-&gt;dup_pixel_count = i &amp; 0x7F; <I><FONT COLOR="#B22222">/* number of dups after this one */</FONT></I></span>
<span class="lineNum">     153 </span><span class="lineCov">            1518:       sinfo-&gt;block_count = 0;	<I><FONT COLOR="#B22222">/* then read new block header */</FONT></I></span>
<span class="lineNum">     154 </span>                :     } <B><FONT COLOR="#A020F0">else</FONT></B> {
<span class="lineNum">     155 </span><span class="lineCov">            2690:       sinfo-&gt;block_count = i &amp; 0x7F; <I><FONT COLOR="#B22222">/* number of pixels after this one */</FONT></I></span>
<span class="lineNum">     156 </span>                :     }
<span class="lineNum">     157 </span>                :   }
<span class="lineNum">     158 </span>                : 
<span class="lineNum">     159 </span>                :   <I><FONT COLOR="#B22222">/* Read next pixel */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">           61609: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">           41258: branch 1 taken</span>
</span><span class="lineNum">     160 </span><span class="lineCov">          102867:   <B><FONT COLOR="#A020F0">for</FONT></B> (i = 0; i &lt; sinfo-&gt;pixel_size; i++) {</span>
<span class="lineNum">     161 </span><span class="lineCov">           61609:     sinfo-&gt;tga_pixel[i] = (U_CHAR) getc(infile);</span>
<span class="lineNum">     162 </span>                :   }
<span class="lineNum">     163 </span>                : }
<span class="lineNum">     164 </span>                : 
<span class="lineNum">     165 </span>                : 
<span class="lineNum">     166 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">     167 </span>                :  * Read one row of pixels.
<span class="lineNum">     168 </span>                :  *
<span class="lineNum">     169 </span>                :  * We provide several different versions depending on input file format.
<span class="lineNum">     170 </span>                :  */</FONT></I>
<span class="lineNum">     171 </span>                : 
<span class="lineNum">     172 </span>                : 
<span class="lineNum">     173 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(JDIMENSION)
<span class="lineNum">     174 </span><span class="lineCov">           33258: <B><FONT COLOR="#0000FF">get_8bit_gray_row</FONT></B> (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)</span>
<span class="lineNum">     175 </span>                : <I><FONT COLOR="#B22222">/* This version is for reading 8-bit grayscale pixels */</FONT></I>
<span class="lineNum">     176 </span>                : {
<span class="lineNum">     177 </span><span class="lineCov">           33258:   tga_source_ptr source = (tga_source_ptr) sinfo;</span>
<span class="lineNum">     178 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JSAMPROW ptr;
<span class="lineNum">     179 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JDIMENSION col;
<span class="lineNum">     180 </span>                :   
<span class="lineNum">     181 </span><span class="lineCov">           33258:   ptr = source-&gt;pub.buffer[0];</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">          215744: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">           32728: branch 1 taken</span>
</span><span class="lineNum">     182 </span><span class="lineCov">          248472:   <B><FONT COLOR="#A020F0">for</FONT></B> (col = cinfo-&gt;image_width; col &gt; 0; col--) {</span>
<span class="lineNum">     183 </span><span class="lineCov">          215744:     (*source-&gt;read_pixel) (source); <I><FONT COLOR="#B22222">/* Load next pixel into tga_pixel */</FONT></I></span>
<span class="lineNum">     184 </span><span class="lineCov">          215214:     *ptr++ = (JSAMPLE) UCH(source-&gt;tga_pixel[0]);</span>
<span class="lineNum">     185 </span>                :   }
<span class="lineNum">     186 </span><span class="lineCov">           32728:   <B><FONT COLOR="#A020F0">return</FONT></B> 1;</span>
<span class="lineNum">     187 </span>                : }
<span class="lineNum">     188 </span>                : 
<span class="lineNum">     189 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(JDIMENSION)
<span class="lineNum">     190 </span><span class="lineNoCov">               0: <B><FONT COLOR="#0000FF">get_8bit_row</FONT></B> (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)</span>
<span class="lineNum">     191 </span>                : <I><FONT COLOR="#B22222">/* This version is for reading 8-bit colormap indexes */</FONT></I>
<span class="lineNum">     192 </span>                : {
<span class="lineNum">     193 </span><span class="lineNoCov">               0:   tga_source_ptr source = (tga_source_ptr) sinfo;</span>
<span class="lineNum">     194 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> t;
<span class="lineNum">     195 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JSAMPROW ptr;
<span class="lineNum">     196 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JDIMENSION col;
<span class="lineNum">     197 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#228B22">register</FONT></B> JSAMPARRAY colormap = source-&gt;colormap;</span>
<span class="lineNum">     198 </span>                : 
<span class="lineNum">     199 </span><span class="lineNoCov">               0:   ptr = source-&gt;pub.buffer[0];</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchNotTaken">               0: branch 1 not taken</span>
</span><span class="lineNum">     200 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#A020F0">for</FONT></B> (col = cinfo-&gt;image_width; col &gt; 0; col--) {</span>
<span class="lineNum">     201 </span><span class="lineNoCov">               0:     (*source-&gt;read_pixel) (source); <I><FONT COLOR="#B22222">/* Load next pixel into tga_pixel */</FONT></I></span>
<span class="lineNum">     202 </span><span class="lineNoCov">               0:     t = UCH(source-&gt;tga_pixel[0]);</span>
<span class="lineNum">     203 </span><span class="lineNoCov">               0:     *ptr++ = colormap[0][t];</span>
<span class="lineNum">     204 </span><span class="lineNoCov">               0:     *ptr++ = colormap[1][t];</span>
<span class="lineNum">     205 </span><span class="lineNoCov">               0:     *ptr++ = colormap[2][t];</span>
<span class="lineNum">     206 </span>                :   }
<span class="lineNum">     207 </span><span class="lineNoCov">               0:   <B><FONT COLOR="#A020F0">return</FONT></B> 1;</span>
<span class="lineNum">     208 </span>                : }
<span class="lineNum">     209 </span>                : 
<span class="lineNum">     210 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(JDIMENSION)
<span class="lineNum">     211 </span><span class="lineCov">          314054: <B><FONT COLOR="#0000FF">get_16bit_row</FONT></B> (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)</span>
<span class="lineNum">     212 </span>                : <I><FONT COLOR="#B22222">/* This version is for reading 16-bit pixels */</FONT></I>
<span class="lineNum">     213 </span>                : {
<span class="lineNum">     214 </span><span class="lineCov">          314054:   tga_source_ptr source = (tga_source_ptr) sinfo;</span>
<span class="lineNum">     215 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> t;
<span class="lineNum">     216 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JSAMPROW ptr;
<span class="lineNum">     217 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JDIMENSION col;
<span class="lineNum">     218 </span>                :   
<span class="lineNum">     219 </span><span class="lineCov">          314054:   ptr = source-&gt;pub.buffer[0];</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">         5165422: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">          313674: branch 1 taken</span>
</span><span class="lineNum">     220 </span><span class="lineCov">         5479096:   <B><FONT COLOR="#A020F0">for</FONT></B> (col = cinfo-&gt;image_width; col &gt; 0; col--) {</span>
<span class="lineNum">     221 </span><span class="lineCov">         5165422:     (*source-&gt;read_pixel) (source); <I><FONT COLOR="#B22222">/* Load next pixel into tga_pixel */</FONT></I></span>
<span class="lineNum">     222 </span><span class="lineCov">         5165042:     t = UCH(source-&gt;tga_pixel[0]);</span>
<span class="lineNum">     223 </span><span class="lineCov">         5165042:     t += UCH(source-&gt;tga_pixel[1]) &lt;&lt; 8;</span>
<span class="lineNum">     224 </span>                :     <I><FONT COLOR="#B22222">/* We expand 5 bit data to 8 bit sample width.
<span class="lineNum">     225 </span>                :      * The format of the 16-bit (LSB first) input word is
<span class="lineNum">     226 </span>                :      *     xRRRRRGGGGGBBBBB
<span class="lineNum">     227 </span>                :      */</FONT></I>
<span class="lineNum">     228 </span><span class="lineCov">         5165042:     ptr[2] = (JSAMPLE) c5to8bits[t &amp; 0x1F];</span>
<span class="lineNum">     229 </span><span class="lineCov">         5165042:     t &gt;&gt;= 5;</span>
<span class="lineNum">     230 </span><span class="lineCov">         5165042:     ptr[1] = (JSAMPLE) c5to8bits[t &amp; 0x1F];</span>
<span class="lineNum">     231 </span><span class="lineCov">         5165042:     t &gt;&gt;= 5;</span>
<span class="lineNum">     232 </span><span class="lineCov">         5165042:     ptr[0] = (JSAMPLE) c5to8bits[t &amp; 0x1F];</span>
<span class="lineNum">     233 </span><span class="lineCov">         5165042:     ptr += 3;</span>
<span class="lineNum">     234 </span>                :   }
<span class="lineNum">     235 </span><span class="lineCov">          313674:   <B><FONT COLOR="#A020F0">return</FONT></B> 1;</span>
<span class="lineNum">     236 </span>                : }
<span class="lineNum">     237 </span>                : 
<span class="lineNum">     238 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(JDIMENSION)
<span class="lineNum">     239 </span><span class="lineCov">           23350: <B><FONT COLOR="#0000FF">get_24bit_row</FONT></B> (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)</span>
<span class="lineNum">     240 </span>                : <I><FONT COLOR="#B22222">/* This version is for reading 24-bit pixels */</FONT></I>
<span class="lineNum">     241 </span>                : {
<span class="lineNum">     242 </span><span class="lineCov">           23350:   tga_source_ptr source = (tga_source_ptr) sinfo;</span>
<span class="lineNum">     243 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JSAMPROW ptr;
<span class="lineNum">     244 </span>                :   <B><FONT COLOR="#228B22">register</FONT></B> JDIMENSION col;
<span class="lineNum">     245 </span>                :   
<span class="lineNum">     246 </span><span class="lineCov">           23350:   ptr = source-&gt;pub.buffer[0];</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">          351190: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">           23244: branch 1 taken</span>
</span><span class="lineNum">     247 </span><span class="lineCov">          374434:   <B><FONT COLOR="#A020F0">for</FONT></B> (col = cinfo-&gt;image_width; col &gt; 0; col--) {</span>
<span class="lineNum">     248 </span><span class="lineCov">          351190:     (*source-&gt;read_pixel) (source); <I><FONT COLOR="#B22222">/* Load next pixel into tga_pixel */</FONT></I></span>
<span class="lineNum">     249 </span><span class="lineCov">          351084:     *ptr++ = (JSAMPLE) UCH(source-&gt;tga_pixel[2]); <I><FONT COLOR="#B22222">/* change BGR to RGB order */</FONT></I></span>
<span class="lineNum">     250 </span><span class="lineCov">          351084:     *ptr++ = (JSAMPLE) UCH(source-&gt;tga_pixel[1]);</span>
<span class="lineNum">     251 </span><span class="lineCov">          351084:     *ptr++ = (JSAMPLE) UCH(source-&gt;tga_pixel[0]);</span>
<span class="lineNum">     252 </span>                :   }
<span class="lineNum">     253 </span><span class="lineCov">           23244:   <B><FONT COLOR="#A020F0">return</FONT></B> 1;</span>
<span class="lineNum">     254 </span>                : }
<span class="lineNum">     255 </span>                : 
<span class="lineNum">     256 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">     257 </span>                :  * Targa also defines a 32-bit pixel format with order B,G,R,A.
<span class="lineNum">     258 </span>                :  * We presently ignore the attribute byte, so the code for reading
<span class="lineNum">     259 </span>                :  * these pixels is identical to the 24-bit routine above.
<span class="lineNum">     260 </span>                :  * This works because the actual pixel length is only known to read_pixel.
<span class="lineNum">     261 </span>                :  */</FONT></I>
<span class="lineNum">     262 </span>                : 
<span class="lineNum">     263 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <FONT COLOR="#B8860B">get_32bit_row</FONT>  get_24bit_row
<span class="lineNum">     264 </span>                : 
<span class="lineNum">     265 </span>                : 
<span class="lineNum">     266 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">     267 </span>                :  * This method is for re-reading the input data in standard top-down
<span class="lineNum">     268 </span>                :  * row order.  The entire image has already been read into whole_image
<span class="lineNum">     269 </span>                :  * with proper conversion of pixel format, but it's in a funny row order.
<span class="lineNum">     270 </span>                :  */</FONT></I>
<span class="lineNum">     271 </span>                : 
<span class="lineNum">     272 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(JDIMENSION)
<span class="lineNum">     273 </span><span class="lineCov">          338870: <B><FONT COLOR="#0000FF">get_memory_row</FONT></B> (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)</span>
<span class="lineNum">     274 </span>                : {
<span class="lineNum">     275 </span><span class="lineCov">          338870:   tga_source_ptr source = (tga_source_ptr) sinfo;</span>
<span class="lineNum">     276 </span>                :   JDIMENSION source_row;
<span class="lineNum">     277 </span>                : 
<span class="lineNum">     278 </span>                :   <I><FONT COLOR="#B22222">/* Compute row of source that maps to current_row of normal order */</FONT></I>
<span class="lineNum">     279 </span>                :   <I><FONT COLOR="#B22222">/* For now, assume image is bottom-up and not interlaced. */</FONT></I>
<span class="lineNum">     280 </span>                :   <I><FONT COLOR="#B22222">/* NEEDS WORK to support interlaced images! */</FONT></I>
<span class="lineNum">     281 </span><span class="lineCov">          338870:   source_row = cinfo-&gt;image_height - source-&gt;current_row - 1;</span>
<span class="lineNum">     282 </span>                : 
<span class="lineNum">     283 </span>                :   <I><FONT COLOR="#B22222">/* Fetch that row from virtual array */</FONT></I>
<span class="lineNum">     284 </span><span class="lineCov">          677740:   source-&gt;pub.buffer = (*cinfo-&gt;mem-&gt;access_virt_sarray)</span>
<span class="lineNum">     285 </span><span class="lineCov">          338870:     ((j_common_ptr) cinfo, source-&gt;whole_image,</span>
<span class="lineNum">     286 </span>                :      source_row, (JDIMENSION) 1, FALSE);
<span class="lineNum">     287 </span>                : 
<span class="lineNum">     288 </span><span class="lineCov">          338870:   source-&gt;current_row++;</span>
<span class="lineNum">     289 </span><span class="lineCov">          338870:   <B><FONT COLOR="#A020F0">return</FONT></B> 1;</span>
<span class="lineNum">     290 </span>                : }
<span class="lineNum">     291 </span>                : 
<span class="lineNum">     292 </span>                : 
<span class="lineNum">     293 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">     294 </span>                :  * This method loads the image into whole_image during the first call on
<span class="lineNum">     295 </span>                :  * get_pixel_rows.  The get_pixel_rows pointer is then adjusted to call
<span class="lineNum">     296 </span>                :  * get_memory_row on subsequent calls.
<span class="lineNum">     297 </span>                :  */</FONT></I>
<span class="lineNum">     298 </span>                : 
<span class="lineNum">     299 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(JDIMENSION)
<span class="lineNum">     300 </span><span class="lineCov">            3025: <B><FONT COLOR="#0000FF">preload_image</FONT></B> (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)</span>
<span class="lineNum">     301 </span>                : {
<span class="lineNum">     302 </span><span class="lineCov">            3025:   tga_source_ptr source = (tga_source_ptr) sinfo;</span>
<span class="lineNum">     303 </span>                :   JDIMENSION row;
<span class="lineNum">     304 </span><span class="lineCov">            3025:   cd_progress_ptr progress = (cd_progress_ptr) cinfo-&gt;progress;</span>
<span class="lineNum">     305 </span>                : 
<span class="lineNum">     306 </span>                :   <I><FONT COLOR="#B22222">/* Read the data into a virtual array in input-file row order. */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">          359549: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">            2086: branch 1 taken</span>
</span><span class="lineNum">     307 </span><span class="lineCov">          361635:   <B><FONT COLOR="#A020F0">for</FONT></B> (row = 0; row &lt; cinfo-&gt;image_height; row++) {</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchTaken">          359549: branch 1 taken</span>
</span><span class="lineNum">     308 </span><span class="lineCov">          359549:     <B><FONT COLOR="#A020F0">if</FONT></B> (progress != NULL) {</span>
<span class="lineNum">     309 </span><span class="lineNoCov">               0:       progress-&gt;pub.pass_counter = (<B><FONT COLOR="#228B22">long</FONT></B>) row;</span>
<span class="lineNum">     310 </span><span class="lineNoCov">               0:       progress-&gt;pub.pass_limit = (<B><FONT COLOR="#228B22">long</FONT></B>) cinfo-&gt;image_height;</span>
<span class="lineNum">     311 </span><span class="lineNoCov">               0:       (*progress-&gt;pub.progress_monitor) ((j_common_ptr) cinfo);</span>
<span class="lineNum">     312 </span>                :     }
<span class="lineNum">     313 </span><span class="lineCov">          719098:     source-&gt;pub.buffer = (*cinfo-&gt;mem-&gt;access_virt_sarray)</span>
<span class="lineNum">     314 </span><span class="lineCov">          359549:       ((j_common_ptr) cinfo, source-&gt;whole_image, row, (JDIMENSION) 1, TRUE);</span>
<span class="lineNum">     315 </span><span class="lineCov">          359549:     (*source-&gt;get_pixel_rows) (cinfo, sinfo);</span>
<span class="lineNum">     316 </span>                :   }
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchTaken">            2086: branch 1 taken</span>
</span><span class="lineNum">     317 </span><span class="lineCov">            2086:   <B><FONT COLOR="#A020F0">if</FONT></B> (progress != NULL)</span>
<span class="lineNum">     318 </span><span class="lineNoCov">               0:     progress-&gt;completed_extra_passes++;</span>
<span class="lineNum">     319 </span>                : 
<span class="lineNum">     320 </span>                :   <I><FONT COLOR="#B22222">/* Set up to read from the virtual array in unscrambled order */</FONT></I>
<span class="lineNum">     321 </span><span class="lineCov">            2086:   source-&gt;pub.get_pixel_rows = get_memory_row;</span>
<span class="lineNum">     322 </span><span class="lineCov">            2086:   source-&gt;current_row = 0;</span>
<span class="lineNum">     323 </span>                :   <I><FONT COLOR="#B22222">/* And read the first row */</FONT></I>
<span class="lineNum">     324 </span><span class="lineCov">            2086:   <B><FONT COLOR="#A020F0">return</FONT></B> get_memory_row(cinfo, sinfo);</span>
<span class="lineNum">     325 </span>                : }
<span class="lineNum">     326 </span>                : 
<span class="lineNum">     327 </span>                : 
<span class="lineNum">     328 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">     329 </span>                :  * Read the file header; return image size and component count.
<span class="lineNum">     330 </span>                :  */</FONT></I>
<span class="lineNum">     331 </span>                : 
<span class="lineNum">     332 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(<B><FONT COLOR="#228B22">void</FONT></B>)
<span class="lineNum">     333 </span><span class="lineCov">            3680: <B><FONT COLOR="#0000FF">start_input_tga</FONT></B> (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)</span>
<span class="lineNum">     334 </span>                : {
<span class="lineNum">     335 </span><span class="lineCov">            3680:   tga_source_ptr source = (tga_source_ptr) sinfo;</span>
<span class="lineNum">     336 </span>                :   U_CHAR targaheader[18];
<span class="lineNum">     337 </span>                :   <B><FONT COLOR="#228B22">int</FONT></B> idlen, cmaptype, subtype, flags, interlace_type, components;
<span class="lineNum">     338 </span>                :   <B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> width, height, maplen;
<span class="lineNum">     339 </span>                :   boolean is_bottom_up;
<span class="lineNum">     340 </span>                : 
<span class="lineNum">     341 </span>                : #<B><FONT COLOR="#5F9EA0">define</FONT></B> <B><FONT COLOR="#0000FF">GET_2B</FONT></B>(offset)	((unsigned int) UCH(targaheader[offset]) + \
<span class="lineNum">     342 </span>                : 			 (((<B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B>) UCH(targaheader[offset+1])) &lt;&lt; 8))
<span class="lineNum">     343 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              17: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">            3663: branch 2 taken</span>
</span><span class="lineNum">     344 </span><span class="lineCov">            3680:   <B><FONT COLOR="#A020F0">if</FONT></B> (! ReadOK(source-&gt;pub.input_file, targaheader, 18))</span>
<span class="lineNum">     345 </span><span class="lineCov">              17:     ERREXIT(cinfo, JERR_INPUT_EOF);</span>
<span class="lineNum">     346 </span>                : 
<span class="lineNum">     347 </span>                :   <I><FONT COLOR="#B22222">/* Pretend &quot;15-bit&quot; pixels are 16-bit --- we ignore attribute bit anyway */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              29: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">            3634: branch 1 taken</span>
</span><span class="lineNum">     348 </span><span class="lineCov">            3663:   <B><FONT COLOR="#A020F0">if</FONT></B> (targaheader[16] == 15)</span>
<span class="lineNum">     349 </span><span class="lineCov">              29:     targaheader[16] = 16;</span>
<span class="lineNum">     350 </span>                : 
<span class="lineNum">     351 </span><span class="lineCov">            3663:   idlen = UCH(targaheader[0]);</span>
<span class="lineNum">     352 </span><span class="lineCov">            3663:   cmaptype = UCH(targaheader[1]);</span>
<span class="lineNum">     353 </span><span class="lineCov">            3663:   subtype = UCH(targaheader[2]);</span>
<span class="lineNum">     354 </span><span class="lineCov">            3663:   maplen = GET_2B(5);</span>
<span class="lineNum">     355 </span><span class="lineCov">            3663:   width = GET_2B(12);</span>
<span class="lineNum">     356 </span><span class="lineCov">            3663:   height = GET_2B(14);</span>
<span class="lineNum">     357 </span><span class="lineCov">            3663:   source-&gt;pixel_size = UCH(targaheader[16]) &gt;&gt; 3;</span>
<span class="lineNum">     358 </span><span class="lineCov">            3663:   flags = UCH(targaheader[17]);	<I><FONT COLOR="#B22222">/* Image Descriptor byte */</FONT></I></span>
<span class="lineNum">     359 </span>                : 
<span class="lineNum">     360 </span><span class="lineCov">            3663:   is_bottom_up = ((flags &amp; 0x20) == 0);	<I><FONT COLOR="#B22222">/* bit 5 set =&gt; top-down */</FONT></I></span>
<span class="lineNum">     361 </span><span class="lineCov">            3663:   interlace_type = flags &gt;&gt; 6;	<I><FONT COLOR="#B22222">/* bits 6/7 are interlace code */</FONT></I></span>
<span class="lineNum">     362 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">            3640: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              23: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">            3623: branch 2 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              17: branch 3 taken</span>
</span><span class="lineNum">     363 </span><span class="lineCov">            7303:   <B><FONT COLOR="#A020F0">if</FONT></B> (cmaptype &gt; 1 ||		<I><FONT COLOR="#B22222">/* cmaptype must be 0 or 1 */</FONT></I></span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">            3606: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              17: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">            3589: branch 2 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              17: branch 3 taken</span>
</span><span class="lineNum">     364 </span><span class="lineCov">           10869:       source-&gt;pixel_size &lt; 1 || source-&gt;pixel_size &gt; 4 ||</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              19: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">            3570: branch 1 taken</span>
</span><span class="lineNum">     365 </span><span class="lineCov">            7195:       (UCH(targaheader[16]) &amp; 7) != 0 || <I><FONT COLOR="#B22222">/* bits/pixel must be multiple of 8 */</FONT></I></span>
<span class="lineNum">     366 </span>                :       interlace_type != 0)	<I><FONT COLOR="#B22222">/* currently don't allow interlaced image */</FONT></I>
<span class="lineNum">     367 </span><span class="lineCov">              93:     ERREXIT(cinfo, JERR_TGA_BADPARMS);</span>
<span class="lineNum">     368 </span>                :   
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">            1264: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">            2306: branch 1 taken</span>
</span><span class="lineNum">     369 </span><span class="lineCov">            3570:   <B><FONT COLOR="#A020F0">if</FONT></B> (subtype &gt; 8) {</span>
<span class="lineNum">     370 </span>                :     <I><FONT COLOR="#B22222">/* It's an RLE-coded file */</FONT></I>
<span class="lineNum">     371 </span><span class="lineCov">            1264:     source-&gt;read_pixel = read_rle_pixel;</span>
<span class="lineNum">     372 </span><span class="lineCov">            1264:     source-&gt;block_count = source-&gt;dup_pixel_count = 0;</span>
<span class="lineNum">     373 </span><span class="lineCov">            1264:     subtype -= 8;</span>
<span class="lineNum">     374 </span>                :   } <B><FONT COLOR="#A020F0">else</FONT></B> {
<span class="lineNum">     375 </span>                :     <I><FONT COLOR="#B22222">/* Non-RLE file */</FONT></I>
<span class="lineNum">     376 </span><span class="lineCov">            2306:     source-&gt;read_pixel = read_non_rle_pixel;</span>
<span class="lineNum">     377 </span>                :   }
<span class="lineNum">     378 </span>                : 
<span class="lineNum">     379 </span>                :   <I><FONT COLOR="#B22222">/* Now should have subtype 1, 2, or 3 */</FONT></I>
<span class="lineNum">     380 </span><span class="lineCov">            3570:   components = 3;		<I><FONT COLOR="#B22222">/* until proven different */</FONT></I></span>
<span class="lineNum">     381 </span><span class="lineCov">            3570:   cinfo-&gt;in_color_space = JCS_RGB;</span>
<span class="lineNum">     382 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              46: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">            2690: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             797: branch 2 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              37: branch 3 taken</span>
</span><span class="lineNum">     383 </span><span class="lineCov">            3570:   <B><FONT COLOR="#A020F0">switch</FONT></B> (subtype) {</span>
<span class="lineNum">     384 </span>                :   <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">1</FONT></B>:			<I><FONT COLOR="#B22222">/* Colormapped image */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              28: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              18: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              11: branch 2 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              17: branch 3 taken</span>
</span><span class="lineNum">     385 </span><span class="lineCov">              46:     <B><FONT COLOR="#A020F0">if</FONT></B> (source-&gt;pixel_size == 1 &amp;&amp; cmaptype == 1)</span>
<span class="lineNum">     386 </span><span class="lineCov">              11:       source-&gt;get_pixel_rows = get_8bit_row;</span>
<span class="lineNum">     387 </span>                :     <B><FONT COLOR="#A020F0">else</FONT></B>
<span class="lineNum">     388 </span><span class="lineCov">              35:       ERREXIT(cinfo, JERR_TGA_BADPARMS);</span>
<span class="lineNum">     389 </span><span class="lineCov">              11:     TRACEMS2(cinfo, 1, JTRC_TGA_MAPPED, width, height);</span>
<span class="lineNum">     390 </span><span class="lineCov">              11:     <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     391 </span>                :   <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">2</FONT></B>:			<I><FONT COLOR="#B22222">/* RGB image */</FONT></I>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">            2348: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              99: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             226: branch 2 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              17: branch 3 taken</span>
</span><span class="lineNum">     392 </span><span class="lineCov">            2690:     <B><FONT COLOR="#A020F0">switch</FONT></B> (source-&gt;pixel_size) {</span>
<span class="lineNum">     393 </span>                :     <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">2</FONT></B>:
<span class="lineNum">     394 </span><span class="lineCov">            2348:       source-&gt;get_pixel_rows = get_16bit_row;</span>
<span class="lineNum">     395 </span><span class="lineCov">            2348:       <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     396 </span>                :     <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">3</FONT></B>:
<span class="lineNum">     397 </span><span class="lineCov">              99:       source-&gt;get_pixel_rows = get_24bit_row;</span>
<span class="lineNum">     398 </span><span class="lineCov">              99:       <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     399 </span>                :     <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">4</FONT></B>:
<span class="lineNum">     400 </span><span class="lineCov">             226:       source-&gt;get_pixel_rows = get_32bit_row;</span>
<span class="lineNum">     401 </span><span class="lineCov">             226:       <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     402 </span>                :     <B><FONT COLOR="#5F9EA0">default</FONT></B>:
<span class="lineNum">     403 </span><span class="lineCov">              17:       ERREXIT(cinfo, JERR_TGA_BADPARMS);</span>
<span class="lineNum">     404 </span><span class="lineNoCov">               0:       <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     405 </span>                :     }
<span class="lineNum">     406 </span><span class="lineCov">            2673:     TRACEMS2(cinfo, 1, JTRC_TGA, width, height);</span>
<span class="lineNum">     407 </span><span class="lineCov">            2673:     <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     408 </span>                :   <B><FONT COLOR="#A020F0">case</FONT></B> <B><FONT COLOR="#5F9EA0">3</FONT></B>:			<I><FONT COLOR="#B22222">/* Grayscale image */</FONT></I>
<span class="lineNum">     409 </span><span class="lineCov">             797:     components = 1;</span>
<span class="lineNum">     410 </span><span class="lineCov">             797:     cinfo-&gt;in_color_space = JCS_GRAYSCALE;</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">             780: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              17: branch 1 taken</span>
</span><span class="lineNum">     411 </span><span class="lineCov">             797:     <B><FONT COLOR="#A020F0">if</FONT></B> (source-&gt;pixel_size == 1)</span>
<span class="lineNum">     412 </span><span class="lineCov">             780:       source-&gt;get_pixel_rows = get_8bit_gray_row;</span>
<span class="lineNum">     413 </span>                :     <B><FONT COLOR="#A020F0">else</FONT></B>
<span class="lineNum">     414 </span><span class="lineCov">              17:       ERREXIT(cinfo, JERR_TGA_BADPARMS);</span>
<span class="lineNum">     415 </span><span class="lineCov">             780:     TRACEMS2(cinfo, 1, JTRC_TGA_GRAY, width, height);</span>
<span class="lineNum">     416 </span><span class="lineCov">             780:     <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     417 </span>                :   <B><FONT COLOR="#5F9EA0">default</FONT></B>:
<span class="lineNum">     418 </span><span class="lineCov">              37:     ERREXIT(cinfo, JERR_TGA_BADPARMS);</span>
<span class="lineNum">     419 </span><span class="lineNoCov">               0:     <B><FONT COLOR="#A020F0">break</FONT></B>;</span>
<span class="lineNum">     420 </span>                :   }
<span class="lineNum">     421 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">            3205: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">             259: branch 1 taken</span>
</span><span class="lineNum">     422 </span><span class="lineCov">            3464:   <B><FONT COLOR="#A020F0">if</FONT></B> (is_bottom_up) {</span>
<span class="lineNum">     423 </span>                :     <I><FONT COLOR="#B22222">/* Create a virtual array to buffer the upside-down image. */</FONT></I>
<span class="lineNum">     424 </span><span class="lineCov">            6410:     source-&gt;whole_image = (*cinfo-&gt;mem-&gt;request_virt_sarray)</span>
<span class="lineNum">     425 </span><span class="lineCov">            3205:       ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,</span>
<span class="lineNum">     426 </span>                :        (JDIMENSION) width * components, (JDIMENSION) height, (JDIMENSION) 1);
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchTaken">            3205: branch 1 taken</span>
</span><span class="lineNum">     427 </span><span class="lineCov">            3205:     <B><FONT COLOR="#A020F0">if</FONT></B> (cinfo-&gt;progress != NULL) {</span>
<span class="lineNum">     428 </span><span class="lineNoCov">               0:       cd_progress_ptr progress = (cd_progress_ptr) cinfo-&gt;progress;</span>
<span class="lineNum">     429 </span><span class="lineNoCov">               0:       progress-&gt;total_extra_passes++; <I><FONT COLOR="#B22222">/* count file input as separate pass */</FONT></I></span>
<span class="lineNum">     430 </span>                :     }
<span class="lineNum">     431 </span>                :     <I><FONT COLOR="#B22222">/* source-&gt;pub.buffer will point to the virtual array. */</FONT></I>
<span class="lineNum">     432 </span><span class="lineCov">            3205:     source-&gt;pub.buffer_height = 1; <I><FONT COLOR="#B22222">/* in case anyone looks at it */</FONT></I></span>
<span class="lineNum">     433 </span><span class="lineCov">            3205:     source-&gt;pub.get_pixel_rows = preload_image;</span>
<span class="lineNum">     434 </span>                :   } <B><FONT COLOR="#A020F0">else</FONT></B> {
<span class="lineNum">     435 </span>                :     <I><FONT COLOR="#B22222">/* Don't need a virtual array, but do need a one-row input buffer. */</FONT></I>
<span class="lineNum">     436 </span><span class="lineCov">             259:     source-&gt;whole_image = NULL;</span>
<span class="lineNum">     437 </span><span class="lineCov">             518:     source-&gt;pub.buffer = (*cinfo-&gt;mem-&gt;alloc_sarray)</span>
<span class="lineNum">     438 </span><span class="lineCov">             259:       ((j_common_ptr) cinfo, JPOOL_IMAGE,</span>
<span class="lineNum">     439 </span>                :        (JDIMENSION) width * components, (JDIMENSION) 1);
<span class="lineNum">     440 </span><span class="lineCov">             259:     source-&gt;pub.buffer_height = 1;</span>
<span class="lineNum">     441 </span><span class="lineCov">             259:     source-&gt;pub.get_pixel_rows = source-&gt;get_pixel_rows;</span>
<span class="lineNum">     442 </span>                :   }
<span class="lineNum">     443 </span>                :   
<span class="branchGroup"><span class="lineNum">         </span><span class="branchNotTaken">               0: branch 0 not taken</span>
<span class="lineNum">         </span><span class="branchTaken">            3464: branch 1 taken</span>
</span><span class="lineNum">     444 </span><span class="lineCov">            6928:   <B><FONT COLOR="#A020F0">while</FONT></B> (idlen--)		<I><FONT COLOR="#B22222">/* Throw away ID field */</FONT></I></span>
<span class="lineNum">     445 </span><span class="lineNoCov">               0:     (<B><FONT COLOR="#228B22">void</FONT></B>) read_byte(source);</span>
<span class="lineNum">     446 </span>                : 
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">             134: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">            3330: branch 1 taken</span>
</span><span class="lineNum">     447 </span><span class="lineCov">            3464:   <B><FONT COLOR="#A020F0">if</FONT></B> (maplen &gt; 0) {</span>
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              95: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              39: branch 1 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              38: branch 2 taken</span>
<span class="lineNum">         </span><span class="branchTaken">              57: branch 3 taken</span>
</span><span class="lineNum">     448 </span><span class="lineCov">             134:     <B><FONT COLOR="#A020F0">if</FONT></B> (maplen &gt; 256 || GET_2B(3) != 0)</span>
<span class="lineNum">     449 </span><span class="lineCov">              77:       ERREXIT(cinfo, JERR_TGA_BADCMAP);</span>
<span class="lineNum">     450 </span>                :     <I><FONT COLOR="#B22222">/* Allocate space to store the colormap */</FONT></I>
<span class="lineNum">     451 </span><span class="lineCov">             114:     source-&gt;colormap = (*cinfo-&gt;mem-&gt;alloc_sarray)</span>
<span class="lineNum">     452 </span><span class="lineCov">              57:       ((j_common_ptr) cinfo, JPOOL_IMAGE, (JDIMENSION) maplen, (JDIMENSION) 3);</span>
<span class="lineNum">     453 </span>                :     <I><FONT COLOR="#B22222">/* and read it from the file */</FONT></I>
<span class="lineNum">     454 </span><span class="lineCov">              57:     read_colormap(source, (<B><FONT COLOR="#228B22">int</FONT></B>) maplen, UCH(targaheader[7]));</span>
<span class="lineNum">     455 </span>                :   } <B><FONT COLOR="#A020F0">else</FONT></B> {
<span class="branchGroup"><span class="lineNum">         </span><span class="branchTaken">              27: branch 0 taken</span>
<span class="lineNum">         </span><span class="branchTaken">            3303: branch 1 taken</span>
</span><span class="lineNum">     456 </span><span class="lineCov">            3330:     <B><FONT COLOR="#A020F0">if</FONT></B> (cmaptype)		<I><FONT COLOR="#B22222">/* but you promised a cmap! */</FONT></I></span>
<span class="lineNum">     457 </span><span class="lineCov">              27:       ERREXIT(cinfo, JERR_TGA_BADPARMS);</span>
<span class="lineNum">     458 </span><span class="lineCov">            3303:     source-&gt;colormap = NULL;</span>
<span class="lineNum">     459 </span>                :   }
<span class="lineNum">     460 </span>                : 
<span class="lineNum">     461 </span><span class="lineCov">            3303:   cinfo-&gt;input_components = components;</span>
<span class="lineNum">     462 </span><span class="lineCov">            3303:   cinfo-&gt;data_precision = 8;</span>
<span class="lineNum">     463 </span><span class="lineCov">            3303:   cinfo-&gt;image_width = width;</span>
<span class="lineNum">     464 </span><span class="lineCov">            3303:   cinfo-&gt;image_height = height;</span>
<span class="lineNum">     465 </span><span class="lineCov">            3303: }</span>
<span class="lineNum">     466 </span>                : 
<span class="lineNum">     467 </span>                : 
<span class="lineNum">     468 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">     469 </span>                :  * Finish up at the end of the file.
<span class="lineNum">     470 </span>                :  */</FONT></I>
<span class="lineNum">     471 </span>                : 
<span class="lineNum">     472 </span>                : <B><FONT COLOR="#0000FF">METHODDEF</FONT></B>(<B><FONT COLOR="#228B22">void</FONT></B>)
<span class="lineNum">     473 </span><span class="lineCov">            2216: <B><FONT COLOR="#0000FF">finish_input_tga</FONT></B> (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)</span>
<span class="lineNum">     474 </span>                : {
<span class="lineNum">     475 </span>                :   <I><FONT COLOR="#B22222">/* no work */</FONT></I>
<span class="lineNum">     476 </span><span class="lineCov">            2216: }</span>
<span class="lineNum">     477 </span>                : 
<span class="lineNum">     478 </span>                : 
<span class="lineNum">     479 </span>                : <I><FONT COLOR="#B22222">/*
<span class="lineNum">     480 </span>                :  * The module selection routine for Targa format input.
<span class="lineNum">     481 </span>                :  */</FONT></I>
<span class="lineNum">     482 </span>                : 
<span class="lineNum">     483 </span>                : <B><FONT COLOR="#0000FF">GLOBAL</FONT></B>(cjpeg_source_ptr)
<span class="lineNum">     484 </span><span class="lineCov">            3680: <B><FONT COLOR="#0000FF">jinit_read_targa</FONT></B> (j_compress_ptr cinfo)</span>
<span class="lineNum">     485 </span>                : {
<span class="lineNum">     486 </span>                :   tga_source_ptr source;
<span class="lineNum">     487 </span>                : 
<span class="lineNum">     488 </span>                :   <I><FONT COLOR="#B22222">/* Create module interface object */</FONT></I>
<span class="lineNum">     489 </span><span class="lineCov">            3680:   source = (tga_source_ptr)</span>
<span class="lineNum">     490 </span><span class="lineCov">            3680:       (*cinfo-&gt;mem-&gt;alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,</span>
<span class="lineNum">     491 </span>                : 				  SIZEOF(tga_source_struct));
<span class="lineNum">     492 </span><span class="lineCov">            3680:   source-&gt;cinfo = cinfo;	<I><FONT COLOR="#B22222">/* make back link for subroutines */</FONT></I></span>
<span class="lineNum">     493 </span>                :   <I><FONT COLOR="#B22222">/* Fill in method ptrs, except get_pixel_rows which start_input sets */</FONT></I>
<span class="lineNum">     494 </span><span class="lineCov">            3680:   source-&gt;pub.start_input = start_input_tga;</span>
<span class="lineNum">     495 </span><span class="lineCov">            3680:   source-&gt;pub.finish_input = finish_input_tga;</span>
<span class="lineNum">     496 </span>                : 
<span class="lineNum">     497 </span><span class="lineCov">            3680:   <B><FONT COLOR="#A020F0">return</FONT></B> (cjpeg_source_ptr) source;</span>
<span class="lineNum">     498 </span>                : }
<span class="lineNum">     499 </span>                : 
<span class="lineNum">     500 </span>                : #<B><FONT COLOR="#5F9EA0">endif</FONT></B> <I><FONT COLOR="#B22222">/* TARGA_SUPPORTED */</FONT></I>
</pre>
<hr>
Generated: 2016-04-07&nbsp;18:20 by <a href="http://minormatter.com/zcov">zcov</a><br>
</body>
</html>
